package com.ruyuan.commodity.exception;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 通用异常信息类
 **/
public class CommonErrorMessage {

    private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(CommonErrorMessage.class);

    /**
     * 异常码
     */
    private String code;
    /**
     * 异常信息
     */
    private String message;

    public CommonErrorMessage() {
    }

    public CommonErrorMessage(String code, String message ) {

        this.code = code;
        this.message = message;

    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        CommonErrorMessage that = (CommonErrorMessage) o;

        return new EqualsBuilder()
                .append(code, that.code)
                .append(message, that.message)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(code)
                .append(message)
                .toHashCode();
    }

}
